﻿// -----------------------------------------------------------------------
// <copyright file="LinkedList.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace DataStructures___Exc1
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class LinkedList
    {
        ListNode m_head;

        public LinkedList()
        {
            m_head = null;
        }

        public void MakeEmpty()
        {
            m_head = null;
        }

        public bool IsEmpty()
        {
            return m_head == null;
        }

        public void AddAtBeginning(ItemType i_data)
        {
            ListNode tempNode = new ListNode(i_data);
            tempNode.Next = m_head;
            m_head = tempNode;
        }

        public void RemoveFromBeginning()
        {
            m_head = m_head.Next;
        }

        public ItemType GetHeadFromList()
        {
            return m_head.Data;
        }

        private class ListNode
        {
            ItemType m_data;
            ListNode m_next;
            

            public ListNode(ItemType i_data)
            {
                m_data = new ItemType();
                //m_data.Data = i_data.Data;
                m_data = i_data;

                m_next = null;
            }

            public ItemType Data
            {
                set
                {
                    m_data = value;
                }
                get
                {
                    return m_data;
                }
            }
            public ListNode Next
            {
                set
                {
                    m_next = value;
                }
                get
                {
                    return m_next;
                }
            }
        }

        
    }
}
